/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import napakalaki.Treasure;

/**
 *
 * @author jonnny0
 */
public class TreasureView extends javax.swing.JPanel {

    /**
     * Creates new form TreasureView
     */
    private Treasure treasureModel;
    private boolean selected = false;

    public TreasureView() {
        initComponents();
        
        
    }

    public boolean isSelected() {
        return selected;
    }

    public Treasure getTreasure() {
        return treasureModel;
    }

//    public void paintComponent(Graphics g) {
//        Dimension tamanio = getSize();
//        ImageIcon fondo = new ImageIcon(getClass().getResource("imgs/TESOROS/Gaita.jpg"));
//        g.drawImage(fondo.getImage(), 0, 0, tamanio.width, tamanio.height, null);
//        setOpaque(false);
//        super.paintComponent(g);
//    }
    public void setTreasure(Treasure t) {
        treasureModel = t;
//        coins.setText(Integer.toString(treasureModel.getGoldCoins()));
//        name.setText(treasureModel.getName());
//        minBonus.setText(Integer.toString(treasureModel.getMinBonus()));
//        maxBonus.setText(Integer.toString(treasureModel.getMaxBonus()));
//        type.setText(treasureModel.getType().name());
        //System.out.println(t.getName());
        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imgs/TESOROS/"+t.getName()+".jpg")));

        repaint();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();

        addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                formMouseClicked(evt);
            }
        });

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imgs/TESOROS/A prueba de babas.jpg"))); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents

    private void formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseClicked
        if (selected == true) {        // TODO add your handling code here:
            selected = false;
            setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, Color.white));
            setEnabled(false);            
        } else {
            selected = true;
            setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, Color.red));
            setEnabled(true);
        }
        repaint();
    }//GEN-LAST:event_formMouseClicked
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    // End of variables declaration//GEN-END:variables
}
